import tensorflow as tf
import os
from common import show_picture

if __name__ == '__main__':
    image_path = './lenna.png'

    # 读取图片数据
    image = tf.io.read_file(image_path)
    image = tf.image.decode_png(image)

    show_picture(image, 'lenna.png')
    
    # 逆时针选择 90, k 为旋转次数
    rotated_image = tf.image.rot90(image, k=1)
    show_picture(rotated_image, 'rotated_lenna.png')

    # 将图像数据进行编码
    rotated_image = tf.image.encode_png(rotated_image)
    # 将编码后的数据保存到文件
    tf.io.write_file('rotated_lenna.png', rotated_image)
